<?php

/**

 * The main template file.

 *

 * This is the most generic template file in a WordPress theme

 * and one of the two required files for a theme (the other being style.css).

 * It is used to display a page when nothing more specific matches a query.

 * E.g., it puts together the home page when no home.php file exists.

 * Learn more: http://codex.wordpress.org/Template_Hierarchy

 *

 * @package _s

 */

get_header ();
?>

<!-- 首页内容区域 -->
<div id="index_main">
	<!--首页焦点图 -->
	<div id="index_focus" class="page_width">
		<div class="index_flash pagebox">
			<!--焦点导航 -->
			<?php $index_focuss = get_index_focus(); ?>
			<ul class="btns clearfix" id="BTNS">
				<?php
				for($index_focus_seq = 0; $index_focus_seq < count($index_focuss);$index_focus_seq++) {
					$focus_item = $index_focuss[$index_focus_seq];
				?>
				<li class="<?php echo $index_focus_seq == 0 ? "cur" : "" ?>">
					<a href="<?php echo $focus_item->focus_redirect_url; ?>" target="_blank">
						<img src="<?php echo $focus_item->focus_thumbnail_url;?>" alt="<?php echo $focus_item->focus_text;?>">
					</a>
					<h1>
						<a id="btn_<?php echo $index_focus_seq; ?>" href="<?php echo $focus_item->focus_redirect_url; ?>" target="_blank"><?php echo $focus_item->focus_text;?></a>
					</h1>
				</li>
				<?php 
				}
				?>
			</ul>
			<!--焦点图 -->
			<ul class="box clearifx" id="LIST">
				<?php
				for($index_focus_seq = 0; $index_focus_seq < count($index_focuss);$index_focus_seq++) {
					$focus_item = $index_focuss[$index_focus_seq];
				?>
				<li style="display: list-item;">
					<a href="<?php echo $focus_item->focus_redirect_url; ?>" target="_blank">
						<img src="<?php echo $focus_item->focus_image_url; ?>">
					</a>
				</li>
				<?php 
				}
				?>
			</ul>
		</div>
	</div>
	
	<div id="index_article" class="page_width clearfix">
		<div id="index_classify">
			<?php
			$catno = get_option ( 'nocatid' );
			if (strlen ( $catno ) > 1) {
				$catno = explode ( ",", $catno );
			}
			$cat_args = array (
				'orderby' => 'ID',
				'order' => 'ASC',
				'hide_empty' => false,
				'exclude' => $catno  // 首页排除分类的id
			);
			// 'exclude' => array(3,4,5) 排除多个分类
			$categories = get_categories ( $cat_args );
			foreach ( $categories as $cat ) {
				$catid = $cat->cat_ID;
				query_posts ( "showposts=9&cat=$catid&meta_key=good_gourl&meta_value!=&orderby=date" );
			?>
			<!--首页分类信息 -->
			<div class="pagebox">
				<div class="box_title">
					<em><?php single_cat_title(); ?></em>
					<ul class="the_tags">
			        	<?php wp_list_categories('orderby=id&style=list&title_li=&use_desc_for_title=0&child_of='.$catid); ?>
					</ul>
					<a href="<?php echo get_category_link($catid);?>"title="<?php echo strip_tags(category_description($catid)); ?>">
						更多>>
					</a>
				</div>
				<div class="box_cont">
					<ul class="box_ul">
			        	<?php while (have_posts()) : the_post(); ?>
			        	<li>
				          	<?php
							$price = get_post_meta ( $post->ID, "good_price", true );
							if (empty ( $price )) {
							} else {	
							?>
				          	<h4 class="price_bg">
								<b>￥<?php echo $price; ?></b>
							</h4>
							<?php } ?>
			          		<a href="<?php the_permalink() ?>" title="<?php the_title(); ?>">
			            		<?php
				                  $picurl = get_post_img();
				                  echo '<img src="'.$picurl.'" alt="'.$post->post_title.'" width="270" />'
			          			?>
			          		</a>
						</li>
			        	<?php endwhile; ?>
					</ul>
				</div>
			</div>
			<?php } ?>
		</div>
		
		<!-- 首页边栏 -->
		<div id="index_side" class="pagebox">
			<div class="box_title">
				<em>最新文章</em>
			</div>
			<div class="box_cont">
				<?php
				query_posts('&ignore_sticky_posts=1&meta_key=article_type');
				$postnun=1;
				if(have_posts()):while(have_posts()):the_post();
				?>
				<div class="site_blogitem">
					<h1>
						<a href="<?php the_permalink() ?>" target="_blank">☆&nbsp;<?php the_title(); ?></a>
					</h1>
					<div class="blogitem_content">
						<?php //the_excerpt(); ?>
					</div>
				</div>
				<?php $postnun++; endwhile; else: ?>
				<div class="site_blogitem">
					<h1>抱歉，暂无相关内容！</h1>
				</div>
				<?php endif; ?>
			</div>
		</div>
	</div>
	
	<?php
	$shop_cat = get_option ( 'index_shop_id' );
	if (get_option ( 'index_shop_show' )) {
	?>
	<div id="index_shop" class="pagebox clearfix">
		<div class="box_title">
			<em>好店推荐</em>
			<p class="the_tags"></p>
			<a href="<?php echo get_category_link($shop_cat);?>">更多>> </a>
		</div>
		<div class="box_cont">
			<div class="list">
				<ul>
					<?php
					query_posts ( "showposts=30&cat=" . $shop_cat );
					while ( have_posts () ) : the_post ();
					?>
					<li><a href="<?php the_permalink() ?>"
						title="<?php the_title() ?>"><img width="50" height="50"
						src="<?php echo get_post_meta($post->ID, "haikuo_pic_url", true);?>"
						alt="<?php the_title() ?>" style="display: block;"></a>
					</li>
          			<?php endwhile; ?>
        		</ul>
			</div>
		</div>
	</div>
	<?php } ?>
</div>

<?php get_footer(); ?>
